package com.xlfc.consumer;

import com.xlfc.common.annotion.RpcComponentScan;
import com.xlfc.consumer.controller.HelloController;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.util.Arrays;


public class AnnotationConsumer {
    public static void main(String[] args) throws IOException {
        for(int i=1;i<3;i++){
            AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(ProviderComponentScan.class);
            annotationConfigApplicationContext.start();
//            Arrays.stream(annotationConfigApplicationContext.getBeanDefinitionNames())
//                    .forEach(System.out::println);//打印所有的bean
            HelloController helloController = (HelloController) annotationConfigApplicationContext.getBean("helloController");
            helloController.test();
        }

    }

    @Configuration
    @RpcComponentScan(basePackages = {"com.xlfc.consumer"})
    static public class ProviderComponentScan{

    }
}